﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Woodlands
{
    public class Student
    {
        private string studentId, firstname, middlename, lastname, homephone, mobilephone, emailUni, emailPersonal,
            tline1, tline2, tcity, tpostcode, hline1, hline2, hcity, hpostcode, status, dob;
        private int courseID;

        public Student()
        {
            studentId = "";
            firstname = "";
            middlename = "";
            lastname = "";
            homephone = "";
            mobilephone = "";
            emailUni = "";
            emailPersonal = "";
            tline1 = "";
            tline2 = "";
            tcity = "";
            tpostcode = "";
            hline1 = "";
            hline2 = "";
            hcity = "";
            hpostcode = "";
            status = "";
            courseID = 0;
            dob = "";
        }

        public Student(string studentIdIn, string firstnameIn, string middlenameIn, string lastnameIn, string homephoneIn,
            string mobilephoneIn, string emailUniIn, string emailPersonalIn, string tline1In, string tline2In, string tcityIn,
            string tpostcodeIn, string hline1In, string hline2In, string hcityIn, string hpostcodeIn, int courseIDin, string DOBin)
        {
            studentId = studentIdIn;
            firstname = firstnameIn;
            middlename = middlenameIn;
            lastname = lastnameIn;
            homephone = homephoneIn;
            mobilephone = mobilephoneIn;
            emailUni = emailUniIn;
            emailPersonal = emailPersonalIn;
            tline1 = tline1In;
            tline2 = tline2In;
            tcity = tcityIn;
            tpostcode = tpostcodeIn;
            hline1 = hline1In;
            hline2 = hline2In;
            hcity = hcityIn;
            hpostcode = hpostcodeIn;
            courseID = courseIDin;
            dob = DOBin;
        }

        public async Task create()
        {
            await Database.createStudent(this);
            return;
        }

        public async Task amend()
        {
            await Database.amendStudent(this);
            return;
        }

        public async static Task<Student> search(string IDin)
        {
            return await Database.getStudent(IDin);
        }

        public static string nextID()
        {
            return Database.nextStudentID();
        }


        public async static Task enrol(string studentIDin)
        {
            await Database.enrolStudent(studentIDin);
            return;
        }

        public static void archive(string studentIDin)
        {
            Database.archiveStudent(studentIDin);
        }

        public static async Task<System.Data.DataTable> search(string searchType, string searchString)
        {
            return await Task<System.Data.DataTable>.Run(() => Database.searchStudent(searchType, searchString));
        }

        public string ID
        {
            get { return studentId; }
            set { studentId = value; }
        }

        public string DOB
        {
            get { return dob; }
            set { dob = value; }
        }

        public int CourseID
        {
            get { return courseID; }
            set { courseID = value; }
        }

        public string FirstName
        {
            get { return firstname; }
            set { firstname = value; }
        }

        public string MiddleName
        {
            get { return middlename; }
            set { middlename = value; }
        }

        public string LastName
        {
            get { return lastname; }
            set { lastname = value; }
        }

        public string HomePhone
        {
            get { return homephone; }
            set { homephone = value; }
        }

        public string MobilePhone
        {
            get { return mobilephone; }
            set { mobilephone = value; }
        }

        public string EmailUni
        {
            get { return emailUni; }
            set { emailUni = value; }
        }

        public string EmailPersonal
        {
            get { return emailPersonal; }
            set { emailPersonal = value; }
        }

        public string tLine1
        {
            get { return tline1; }
            set { tline1 = value; }
        }

        public string tLine2
        {
            get { return tline2; }
            set { tline2 = value; }
        }

        public string tCity
        {
            get { return tcity; }
            set { tcity = value; }
        }

        public string tPostCode
        {
            get { return tpostcode; }
            set { tpostcode = value; }
        }

        public string hLine1
        {
            get { return hline1; }
            set { hline1 = value; }
        }

        public string hLine2
        {
            get { return hline2; }
            set { hline2 = value; }
        }

        public string hCity
        {
            get { return hcity; }
            set { hcity = value; }
        }

        public string hPostCode
        {
            get { return hpostcode; }
            set { hpostcode = value; }
        }

        public string Status
        {
            get { return status; }
            set { status = value; }
        }
    }
}